package com.kfm.servlet;

import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import java.io.IOException;

@WebServlet("/third")
public class ThirdServlet implements Servlet {

    public ThirdServlet() {
        // 1. 当servlet被加载【访问绑定的url时候】的时候先实例化
        System.out.println("实例化ThirdServlet对象");
    }
    @Override
    public void init(ServletConfig config) throws ServletException {
        // 2. 实例化完成调用init方法完成初始化
        System.out.println("ThirdServlet init");
    }

    @Override
    public ServletConfig getServletConfig() {
        // 返回当前servlet的配置信息
        return null;
    }

    @Override
    public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
        // 3. 初始化完成 调用service方法提供服务
        System.out.println("ThirdServlet service");
    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {
        // 4. 当web应用被卸载 调用destroy销毁实例
        System.out.println("ThirdServlet destroy");
    }
}
